<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' phải bằng '+min+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('Bạn gặp phải lỗ sau :\n'+errors);
  document.MM_returnValue = (errors == '');
}
//-->
</script>

<script language="JavaScript" type="text/javascript">
						
					    function kiemtra(diem)
						{
						 	var tong=0,i;
							for (i=1; i<= diem; i ++)
							{
								tong= parseFloat(tong)+parseFloat(document.getElementById("alphai"+i).value)
								//alert(i);
							}
							return tong
						}
</script>

<%
					
					rs.open "select * from sanpham where masanpham ="&Session("ma_sp")& " and status=1 ",conn
%>
<body>
    <label>
        Nhập hệ số alpha I của sản phẩm :
    </label>
    <label>
        <%=rs("tensanpham")%>
    </label>
    <%rs.close()%>
    <form action="DanhSachPhieuDiem.asp" method="post" name="chitietthongtin" id="chitietthongtin"
        onsubmit="MM_validateForm('Tổng alpha I','','RinRange1:1');return document.MM_returnValue">
        <table width="100%" border="0">
            <tr>
                <td>
                    Tên thông tin
                </td>
                <td>
                    Hệ số anpha I
                </td>
            </tr>
            <% rs.open "select * from chitietthongtin where masanpham = "& Session("ma_sp"),conn%>
            <% dem=1
					  	while not rs.eof 
            %>
            <tr>
                <td>
                    <%=rs("tenchitietthongtin")%>
                    <input name="machitiettt<%=dem%>" type="hidden" id="machitiettt<%=dem%>" value="<%=rs("machitietthongtin")%>" /></td>
                <td>
                    <input name="alphai<%=dem%>" type="text" id="alphai<%=dem%>" value="<%=rs("alphai")%>"
                        size="3" /></td>
            </tr>
            <%dem = dem +1%>
            <%rs.movenext()%>
            <%wend %>
            <%rs.close()%>
            <tr>
                <td>
                    <div align="right">
                        <input name="Submit" type="submit" onmouseover="document.getElementById('Tổng alpha I').value=kiemtra(<%=dem-1%>)"
                            value="  Nhập  " />
                    </div>
                </td>
                <td>
                    <input name="Tổng alpha I" type="text" id="Tổng alpha I" size="3" readonly="true" />
                    <input name="demso" type="hidden" id="demso" value="<%=dem-1%>" readonly="1" /></td>
            </tr>
        </table>
    </form>
</body>
</html>
